package org.devocean.groupbuying.service.impl;

import java.util.List;

import org.devocean.groupbuying.dao.ArticleDAO;
import org.devocean.groupbuying.domain.Article;
import org.devocean.groupbuying.service.ArticlesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class ArticlesServiceImpl implements ArticlesService {

	@Autowired
	private ArticleDAO articleDAO;

	@Transactional(readOnly = true)
	public List<Article> getArticlesEntries(int firstResult, int maxResults) {
		return articleDAO.findArticlesEntries(firstResult, maxResults);
	}

	@Transactional(readOnly = true)
	public Article getArticleById(Integer id) {
		return articleDAO.findArticleById(id);
	}

	@Transactional
	public void removeArticle(Integer id) {
		articleDAO.deleteArticle(id);

	}

	@Transactional(readOnly = true)
	public long countArticles() {
		return articleDAO.countArticles();
	}

	@Transactional(readOnly = true)
	public List<Article> getArticlesByLang(String lang) {
		return articleDAO.findArticlesByLang(lang);
	}
	@Transactional(readOnly = true)
	public Article getArticleBylang(Integer LocalisationKey, String language) {
		return articleDAO.findArticleBylang(LocalisationKey, language);
	}

}
